OCAMLC = ocamlc
OCAMLLEX = ocamllex
OCAMLYACC = ocamlyacc
OCAMLOPT = ocamlopt 
OCAMLDEP = ocamldep
OCAMLMKLIB = ocamlmklib
OCAMLMKTOP = ocamlmktop
OCAMLDOC = ocamldoc




#-------------------------------------------
# Project name Concise animation language
#-------------------------------------------


PROJECT = cal


LEXFILES:=$(wildcard *.mll)
MLFROMLEX:=$(LEXFILES:.mll=.ml)
YACCFILES:=$(wildcard *.mly)
MLFROMYACC:=$(YACCFILES:.mly=.ml)
MLIFROMYACC:=$(YACCFILES:.mly=.mli)
MLFILES:=$(MLFROMYACC) $(MLFROMLEX) $(filter-out $(MLFROMYACC),$(filter-out $(MLFROMLEX),$(wildcard *.ml)))
OBJS:=$(MLFILES:.ml=.cmo)
OCAMLFLAGS = 

all: .depend $(MLFROMLEX) $(MLFROMYACC) $(PROJECT)

$(MLFROMLEX) : $(LEXFILES)
	$(OCAMLLEX) $^
$(MLFROMYACC) $(MLIFROMYACC): $(YACCFILES)
	$(OCAMLYACC) $^
%.cmi : %.mli
	$(OCAMLC) $(OCAMLFLAGS) -c $<
%.cmo : %.ml
	$(OCAMLC) $(OCAMLFLAGS) -c $<

.depend: $(MLFILES) $(MLIFROMYACC)
	$(OCAMLDEP) $^ > .depend

clean:
	rm -f *.cmi *.cmo .depend .objs $(MLFROMLEX) $(MLFROMYACC) $(MLIFROMYACC)

.PHONY: clean all test

-include .depend

$(PROJECT): $(OBJS)
	$(OCAMLC) $(OCAMLFLAGS) -o $(PROJECT) $^

test: $(PROJECT)
	make -C test
